package cn.idietrade.idietradegoodsmodule8002.utils;

import cn.idietrade.common.pojo.SecondGoods;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitMessagingTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.logging.Logger;

/**
 * @author zjy
 * @version 1.0
 * @createTime 2022-12-06 16:15
 * @description
 */
@Slf4j
@Component
public class RabbitMQUtil {
    @Resource
    private RabbitMessagingTemplate rabbitMessagingTemplate;

    Logger logger = Logger.getLogger("RabbitMQUtil");

    //发送消息到es 同步数据
    public boolean sendMessage(String message){
        try {
            rabbitMessagingTemplate.convertAndSend("syncExchange","sync",message);
            return true;
        }catch (Exception e){
            logger.info("发送消息队列程序异常"+e.getMessage());
            e.printStackTrace();
            return false;
        }
    }
}
